package com.tz.farmer.controller;


import com.smartPark.msframe.result.ResultEx;
import com.tz.farmer.model.WinXinEntity;
import com.tz.farmer.so.BaseSo;
import com.tz.farmer.util.WeinXinUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 微信分享（h5）
 * @name BusinessController
 * @author: xhj
 * @date: 2021/7/13
 * @version V1.0
 */
@RestController
@RequestMapping("share")
@Api(value = "微信分享（h5）", tags = "微信分享（h5）控制器")

public class WxShareController {

    private static Logger logger = LoggerFactory.getLogger(WxShareController.class);


    /**
     * @description:  查询微信分享参数
     * @name businessInfo
     * @author: xhj
     * @date: 2021/7/13 11:35
     * @version V1.0
     */
    @ApiOperation("查询微信分享参数")
    @GetMapping("shareInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "url", value = "", defaultValue = ""),
    })
    public ResultEx getShareInfo(String url) {
        WinXinEntity winXinEntity=null;
        try {
             winXinEntity = WeinXinUtil.getWinXinEntity(url);
        }catch (Exception e){
            logger.error("获取微信分享参数失败",e);
            return ResultEx.builder().makeFailedResult("获取微信分享参数失败");

        }
        return ResultEx.builder().makeSuccessResult(winXinEntity);

    }

}
